import io.netty.util.concurrent.DefaultEventExecutor;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;

public class PromiseMain {


    public static void main(String[] args) throws ExecutionException, InterruptedException {
        System.out.println("123");
//        DefaultEventExecutor executors = new DefaultEventExecutor();
//        executors.submit((Callable<Object>) () -> {
//            System.out.println("123");
//            return "456";
//        }).addListener(future -> System.out.println(future.get()));

        DefaultEventExecutor executors1 = new DefaultEventExecutor();
        executors1.submit((Callable<Object>) () -> {
            System.out.println("submit123");
            return "submit456";
        }).addListener(future -> {
            System.out.println(future.get());
        });
        executors1.newPromise().setSuccess("meizhonghao").addListener(future -> {
                    System.out.println(future.get() + "123");
                }
        ).get();
        System.out.println("789");
        executors1.shutdownGracefully().get();
        System.out.println("789");
    }


}
